#include <iostream>

using namespace std;
#include "Vector.hpp"

class Solution
{
public:
  bool searchMatrix(vector<vector<int>> &matrix, int target)
  {
    size_t rows = matrix.size();
    size_t cols = matrix[0].size();
    size_t count = rows * cols;

    size_t start = 0;
    size_t end = count - 1;

    while (start <= end)
    {
      size_t index = (start + end) / 2;
      int val = matrix[index / cols][index % cols];
      if (val < target)
      {
        start = index + 1;
      }
      else if (val > target)
      {
        end = index - 1;
      }
      else
      {
        return true;
      }
    }
    return false;
  }
};

int main()
{
  cout << "Code74" << endl;
  vector<vector<int>> matrix = vector<vector<int>>{{1}};
  Print2DVector(matrix);
  Solution sol;
  cout << sol.searchMatrix(matrix, 0) << endl;
  return 0;
}